#ifndef __H_TCPCONNECTION_H__
#define __H_TCPCONNECTION_H__
#include "Public.h"

namespace liu
{
	class Channel;
	class Eventloop;

	class TcpConnection : public enable_shared_from_this<TcpConnection>
	{
	public:
		using ReadCallback = function<void()>;
		using WriteCallback = function<void()>;
		using ConnectionCallback = function<void(const shared_ptr<TcpConnection>&)>;

	public:
		TcpConnection(Eventloop* pLoop, int sockfd);
		~TcpConnection();

	public:
		void handleRead();
		void handleWrite();
		void send(const string& msg);
		void connectEstablished();

	public:
		Eventloop* m_pLoop;
		ReadCallback m_readCallback;
		WriteCallback m_writeCallback;
		ConnectionCallback m_connCallback;
		int m_sockfd;
		unique_ptr<Channel> m_pChannel;
	};
}
#endif // __H_TCPCONNECTION_H__